package mm.http;

import java.util.Map;

import net.sf.cglib.reflect.FastClass;

import mm.test.MockContext;
import mm.test.MockContextImpl;
import mm.test.MockRequest;
import mm.test.MockResponse;
import mm.test.MockSession;
import mm.util.ClassicActionInvoker;

import mm.util.ActionInvoker;
import mm.util.LOG;
import mm.view.User;

import junit.framework.TestCase;

public class PageDispatcherTest extends TestCase {

	private static MockContext mockContext=null;

	protected void setUp() throws Exception {
		super.setUp();
		if(mockContext==null)
			mockContext=new MockContextImpl("webapp");
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testDoFilter() throws Exception {
		MockSession mockSession = mockContext.createSession();
		MockRequest mockRequest=mockSession.createRequest();
		mockRequest.setServletPath("/new/go1");
		MockResponse mockResponse=mockRequest.submit();
		LOG.debug("<"+mockResponse.getContent()+">");
		mockRequest=mockSession.createRequest();
		mockRequest.setServletPath("/new/go4");
		mockResponse=mockRequest.submit();
		LOG.debug("<"+mockResponse.getContent()+">");
		mockRequest=mockSession.createRequest();
		mockRequest.setServletPath("/new/go4/123");
		mockResponse=mockRequest.submit();
		LOG.debug("<"+mockResponse.getContent()+">");
		mockRequest=mockSession.createRequest();
		mockRequest.setServletPath("/new/go4/123/456/789");
		mockResponse=mockRequest.submit();
		LOG.debug("<"+mockResponse.getContent()+">");
		mockRequest=mockSession.createRequest();
		mockRequest.setServletPath("/new/go4/123/456/789");
		mockRequest.setParameter("aaa", "xxx");
		mockRequest.setParameter("bbb", "yyy");
		mockRequest.setParameter("ccc", "zzz");
		mockResponse=mockRequest.submit();
		LOG.debug("<"+mockResponse.getContent()+">");
		mockRequest=mockSession.createRequest();
		mockRequest.setServletPath("/new/go5");
		mockResponse=mockRequest.submit();
		LOG.debug("<"+mockResponse.getContent()+">");
		mockRequest=mockSession.createRequest();
		mockRequest.setServletPath("/new/go6");
		mockResponse=mockRequest.submit();
//		mockRequest=mockResponse.getRedirectedRequest();
//		mockResponse=mockRequest.submit();
//		LOG.debug("<"+mockResponse.getContent()+">");
	}
	
	public static void main(String[] args) {
		junit.textui.TestRunner.run(PageDispatcherTest.class);
	}

}
